Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: features OTCR natively in canary #3061

Draft
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

kokekanon
Copy link
Contributor

@kokekanon kokekanon commented Nov 4, 2024

6/6

for test use this client.exe https://github.com/mehah/otclient/actions/runs/11730256085
or use this in terminal

ProtocolGame.registerOpcode(0x43, function(protocol, msg)
    local count = msg:getU16()
    for i = 1, count do
      local feature = msg:getU8()
	  local enable = msg:getU8()
	  if enable == 1 then
		g_game.enableFeature(feature)
	  end
	end
end)

Description

Feature Done No break v8 or cipsoft
1.- Creature AE + Shader
2.- send disableFeature / enableFeature . easy to modify in config.lua mehah/otclient#962
3.- outfit (wings,aura,shader)
4.- TypingIcon
5.- map shader support
6- item Shader

1.-Creature AE + Shader

no break cipsoft or v8
image
img
Haskanoid Video

2.-send disableFeature / enableFeature . easy to modify in config.lua

it is easier for the server administrator to modify config.lua than to compile every time he wants to add or remove a feature.
note1: v8 and otcr send the same packets, so it could be only 1 function, but i don't want to break anything.

note2 : In otcr requires modification in the client * is not yet ready

image

3.- outfit (wings,aura,shader)

image

4.- TypingIcon

Haskanoid Video

5.- map shader support

Peoplemon by Alex Stuart

6.- item Shader

Peoplemon by Alex Stuart

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested

1/6 Creature : AttachedEffect | Shader

Client:
--   g_game.enableFeature(GameCreatureAttachedEffect)
--   g_game.enableFeature(GameCreatureShader)
Server:
	player:setShader("Outfit - Rainbow")
	player:attachEffectById(7)
	player:attachEffectById(8)

2/6 Player: Map Shader

	player:setMapShader("Map - Party")

4/6 feature: Item Shader

--Client:
	g_game.enableFeature(GameItemShader)
-- Server:
	player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK):setShader("Map - Party")

5/6 send disableFeature / enableFeature. easy to modify in config.lua

const auto &enabledFeatures = g_configManager().getEnabledOTCFeatures();
const auto &disabledFeatures = g_configManager().getDisabledOTCFeatures();

for (auto feature : enabledFeatures) {
g_logger().info("Feature enabled: {}", feature);
}

for (auto feature : disabledFeatures) {
g_logger().info("Feature disabled: {}", feature);
}

6/6

image
image

x:addCustomOutfit("aura", 8)
x:removeCustomOutfit("aura", 8)

Test Configuration:

  • Server Version: 13.40
  • Client: OTCR
  • Operating System: 11

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Note: To be honest, I'm not good at C++, and I don't use Canary, I'm not used to the structure.

attachEffectById
detachEffectById
getShader
setShader
player:setMapShader("Map - Party")
src/game/game.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
Copy link
Member

@dudantas dudantas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. I have a few observations that could help further improve the work.

src/creatures/creature.cpp Outdated Show resolved Hide resolved
src/creatures/creature.cpp Outdated Show resolved Hide resolved
src/creatures/creature.hpp Outdated Show resolved Hide resolved
src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/creatures/players/player.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/game/game.cpp Outdated Show resolved Hide resolved
src/items/item.hpp Outdated Show resolved Hide resolved
const auto &enabledFeatures = g_configManager().getEnabledOTCFeatures();
const auto &disabledFeatures = g_configManager().getDisabledOTCFeatures();

				for (int32_t feature : enabledFeatures) {
					g_logger().info("Feature enabled: {}", feature);
				}

				for (int32_t feature : disabledFeatures) {
					g_logger().info("Feature disabled: {}", feature);
				}

Update configmanager.hpp
@@ -695,7 +695,7 @@ class Creature : virtual public Thing, public SharedObject {
std::string getShader() const {
return shader;
}
void setShader(const std::string &shaderName) {
void setShader(const std::string_view &shaderName) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove the & as well; passing a std::string_view by reference actually increases overhead. std::string_view is intended to be passed by value since it is simply a lightweight view of the string.

@@ -1383,7 +1383,7 @@ class Player final : public Creature, public Cylinder, public Bankable {
std::string name;
std::string guildNick;
std::string loyaltyTitle;
std::string mapShader;
std::string_view mapShader;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, it will remain as std::string. std::string_view is used to avoid copying the string, but in the final context where it needs to be stored or modified, it must be a std::string.

@dudantas
Copy link
Member

dudantas commented Nov 5, 2024

Apologies for the confusion. In the setShader method, you can continue using std::string_view, but for all other methods, they can remain as std::string.

PS: If you need, I can help commit.

@dudantas
Copy link
Member

dudantas commented Nov 5, 2024

@kokekanon
I couldn't commit directly to your fork, but here's the commit if you want to cherry pick it
1437b7e

@@ -1719,7 +1719,7 @@ void ProtocolGame::parseSetOutfit(NetworkMessage &msg) {
g_logger().debug("Bool isMounted: {}", isMounted);
}

uint8_t isMountRandomized = msg.getByte();
uint8_t isMountRandomized = !oldProtocol ? msg.getByte() : 0;
Copy link
Contributor Author

@kokekanon kokekanon Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v8 old protocol no send "isMountRandomized" , last packet is newOutfit.lookMount = msg.get<uint16_t>(); canary read in (L1711)

image
https://github.com/opentibiabr/otcv8/blob/main/src/client/protocolgamesend.cpp#L833

Redemption 11.00 no send isMountRandomized only in 13.40

msg.addByte(newOutfit.lookMountBody);
msg.addByte(newOutfit.lookMountLegs);
msg.addByte(newOutfit.lookMountFeet);
}
writeToOutputBuffer(msg);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

load this (sendCreatureOutfit and AddCreature) into AddOutfit
(same packets)
image

msg.addByte(outfit.lookMountBody);
msg.addByte(outfit.lookMountLegs);
msg.addByte(outfit.lookMountFeet);
}
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

load this (sendCreatureOutfit and AddCreature) into AddOutfit
(same packets)
image

kokekanon and others added 20 commits November 7, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants